package test2.spider;

import java.util.HashMap;
import java.util.Map;

public class ThreadLocalUtil {
	
	static ThreadLocal<Map<String, Object>> local = new ThreadLocal<Map<String, Object>>() {
		@Override
		protected Map<String, Object> initialValue() {
			return new HashMap<>();
		}
	};
	
	public static void put(String key, Object obj) {
		local.get().put(key, obj);
	}
	
	@SuppressWarnings("unchecked")
	public static <T> T get(String key) {
		return (T) local.get().get(key);
	}
	
	public static void remove(String key) {
		local.get().remove(key);
	}
	
	public static void remove() {
		local.remove();
	}

}
